﻿/*
    添加轮播广告的JS
*/
function adList(width ,height ,linkarr ,picarr ,textarr) {
    var swf_width = width;
    var swf_height = height;
    var files = "";
    var links = "";
    var texts = "";
    for (i = 0; i < picarr.length; i++) {
        if (files == "") files = picarr[i];
        else files += "|" + picarr[i];
    }
    for (i = 0; i < linkarr.length; i++) {
        if (links == "") links = linkarr[i];
        else links += "|" + linkarr[i];
    }
    for (i = 0; i < textarr.length; i++) {
        if (texts == "") texts = textarr[i];
        else texts += "|" + textarr[i];
    }
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + swf_width + '" height="' + swf_height + '">');
    document.write('<param name="movie" value="Flash/hotnews_player.swf"><param name="quality" value="high">');
    document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
    document.write('<param name="FlashVars" value="bcastr_file=' + files + '&bcastr_link=' + links + '&bcastr_title=' + texts + '">');
    document.write('<embed src="Flash/hotnews_player.swf" wmode="opaque" FlashVars="bcastr_file=' + files + '&bcastr_link=' + links + '&bcastr_title=' + texts + '& menu="false" quality="high" width="' + swf_width + '" height="' + swf_height + '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>');
}


/*
    切换案件委托选项卡
*/
function delegateMsg(obj) { 
    $("#aj_delegate").removeClass();
    $("#localaj_delegate").removeClass();
    changeStyle($("#aj_delegate"), "titleBg");
    changeStyle($("#localaj_delegate"), "titleBg");
    changeStyle($("#" + obj), "titleBg2");
}

/*
    切换首页问答的选项卡标签样式
*/
function askSelect(obj) { 
    $("#new_LayerMessage").removeClass();
    $("#beOver_LayerMessage").removeClass();
    changeStyle($("#new_LayerMessage"), "titleBg");
    changeStyle($("#beOver_LayerMessage"), "titleBg");
    changeStyle($("#" + obj), "titleBg2");
}

/*
    切换首页高分律师和活跃律师的选项卡标签
*/
function LayerSelect(obj) { 
$("#l_Huoyue").removeClass();
$("#l_Zuigao").removeClass();
changeStyle($("#l_Huoyue"), "bkt_menu1");
changeStyle($("#l_Zuigao"), "bkt_menu1");
changeStyle($("#" + obj) ,"bkt_menu");
}

function articleSelectClean(obj ,obj2)
{
	$("#" + obj).removeClass();
	$("#" + obj2).removeClass();
}

function articleSelect(obj ,obj2 ,nowObj){
	articleSelectClean(obj ,obj2);
	changeStyle($("#" + obj), "title_Colum");
	changeStyle($("#" + obj2), "title_Colum");
	changeStyle($("#" + nowObj) ,"title_Colum2");
}

/*
鼠标经过，切换某对象的CSS
*/
function changeStyle(obj, css) {
    obj.addClass(css);
}

/*
    加载问答
*/
function reload_ask(type) {
    //页面的HTML(首页，最新、已解决咨询)
    var html = '<li><div class="left"><a href="/FAQs/askcontent.aspx?id=$ID$" class="message_big_red">[$SmallClassName$]$Title$</a></div><div class="right">$TimeStr$</div></li>';
    //type = 0 是最新 type = 1是已解决
    var url = "/AjaxSource/AskSource.ashx";
    $.getJSON(
        url,
        { type: type, rand: Math.floor(Math.random() * 10000).toString() },
        function (jsonData) {
            var outHtml = '';
            for (var i = 0; i < jsonData.length; ++i) {
                if (outHtml == '')
                    outHtml = html.replace('$Title$', jsonData[i].Title).replace('$TimeStr$', jsonData[i].timeString).replace('$SmallClassName$', jsonData[i].SmallClassName).replace('$ID$', jsonData[i].ID);
                else
                    outHtml += html.replace('$Title$', jsonData[i].Title).replace('$TimeStr$', jsonData[i].timeString).replace('$SmallClassName$', jsonData[i].SmallClassName).replace('$ID$', jsonData[i].ID);
            }
            $("#askBox").empty();
            $("#askBox").html(outHtml);
        }
    );
}

//在线律师
function reload_onlinelayerlist(type) {
    var html = '<li class="fixli"><div class="public_colum1"><a href="/lawyeruser/lawyer.aspx?id=$lawyerid$">[$layername$]</a></div><div class="public_colum2 color_style_1 font_style_1">$provincename$$cityname$</div><div class="public_colum3">律师$point$分</div></li>';
	var url = "/AjaxSource/LayerSource.ashx";
	//type = 2 在线律师
	$.getJSON(
        url,
        { type: type, rand: Math.floor(Math.random() * 10000).toString() },
        function (jsonData) {
            var outHtml='';
            for (var i = 0; i < jsonData.length; ++i) {
                if (outHtml == '')
                    outHtml = html.replace('$layername$', jsonData[i].RealName).replace('$provincename$', jsonData[i].ProvinceName).replace('$cityname$', jsonData[i].CityName).replace('$point$', jsonData[i].Point).replace('$lawyerid$',jsonData[i].ID);
                else
                    outHtml += html.replace('$layername$', jsonData[i].RealName).replace('$provincename$', jsonData[i].ProvinceName).replace('$cityname$', jsonData[i].CityName).replace('$point$', jsonData[i].Point).replace('$lawyerid$', jsonData[i].ID);
            }
            $("#OnlineLayer").empty();
            $("#OnlineLayer").html(outHtml);
        }
    );
}

/*
    加载律师
*/
function reload_layerlist(type) {
    //页面的HTML(首页右侧，最高评分和活跃律师)
    var html = '<li><div class="blc_c1"></div><div class="blc_c2"><a href="/lawyeruser/lawyer.aspx?id=$lawyerid$" class="message_lightbluelink">$layername$律师</a></div><div class="blc_c3"><a href="/lawyeruser/lawyerlist.aspx?cityid=$cityid$" class="message_lightbluelink">$provincename$$cityname$</a></div><div class="blc_c4"><a href="/lawyeruser/lawyer.aspx?id=$lawyerid$" class="gaylink">咨询</a></div></li>';
    //type = 0 是活跃 type = 1是高分
    var url = "/AjaxSource/LayerSource.ashx";
    $.getJSON(
        url,
        { type: type, rand: Math.floor(Math.random() * 10000).toString() },
        function (jsonData) {
            var outHtml='';
            for (var i = 0; i < jsonData.length; ++i) {
                if (outHtml == '')
                    outHtml = html.replace('$layername$', jsonData[i].RealName).replace('$provincename$', jsonData[i].ProvinceName).replace('$cityname$', jsonData[i].CityName).replace('$lawyerid$', jsonData[i].ID).replace('$cityid$', jsonData[i].CityID);
                else
                    outHtml += html.replace('$layername$', jsonData[i].RealName).replace('$provincename$', jsonData[i].ProvinceName).replace('$cityname$', jsonData[i].CityName).replace('$lawyerid$', jsonData[i].ID).replace('$cityid$', jsonData[i].CityID) ;
            }
            $("#layerBox").empty();
            $("#layerBox").html(outHtml);
        }
    );
}

/*
	擅长律师
*/
function reload_lawyerlist(type ,classid ,picobj ,nameobj)
{
	
    var html = '<a href="/lawyeruser/lawyer.aspx?id=$ID$"><img alt="" style="width:110px; height:90px;" src="$picurl$" /></a>';
    //type = 0 是活跃 type = 1是高分
    var url = "/AjaxSource/LayerSource.ashx";
    $.getJSON(
        url,
        { type: type, classid:classid , rand: Math.floor(Math.random() * 10000).toString()},
        function (jsonData) {
            $("#" + picobj).empty();
			$("#" + nameobj).empty();
			if(jsonData.length > 0) {
			    $("#" + picobj).html(html.replace('$picurl$', jsonData[0].HeadPic).replace('$ID$' ,jsonData[0].ID));
				$("#" + nameobj).html('<a href="/lawyeruser/lawyer.aspx?id=' + jsonData[0].ID + '" class="linkcolor6">' + jsonData[0].RealName + '律师' + '</a>');
			}
        }
    );		
}

function reload_alllawyerlist(type ,classid ,obj)
{
    var html = '<div class="namebox"><a href="/lawyeruser/lawyer.aspx?id=$lawyerid$" class="class1">$RealName$</a></div>';
	var url = "/AjaxSource/LayerSource.ashx";
    $.getJSON(
        url,
        { type: type, classid:classid , rand: Math.floor(Math.random() * 10000).toString()},
        function (jsonData) {
			var outHtml='';
			for (var i = 0; i < jsonData.length; ++i) {
				if (outHtml == '')
				    outHtml = html.replace('$RealName$', jsonData[i].RealName).replace('$lawyerid$', jsonData[i].ID);
                else
                    outHtml += html.replace('$RealName$', jsonData[i].RealName).replace('$lawyerid$', jsonData[i].ID);
			}
			$("#" + obj).empty();
			$("#" + obj).html(outHtml);
        }
    );
}

/*
	加载新闻
*/
function reload_newslist(classid ,htmlbox_obj)
{
	var html = '<li>·&nbsp;&nbsp;<a href="/news/NewsContent.aspx?NewsID=$ID$" target="_blank" class="message">$title$</a></li>';
	var url = "/AjaxSource/NewsSource.ashx";
	
	$.getJSON(
        url,
        { classid: classid, rand: Math.floor(Math.random() * 10000).toString() },
        function (jsonData) {
            var outHtml='';
            for (var i = 0; i < jsonData.length; ++i) {
                if (outHtml == '')
                    outHtml = html.replace('$title$', jsonData[i].Title).replace('$ID$' ,jsonData[i].ID);
                else
                    outHtml += html.replace('$title$', jsonData[i].Title.replace('$ID$', jsonData[i].ID));
            }
			
            $("#" + htmlbox_obj).empty();
    		$("#" + htmlbox_obj).html(outHtml);
        }
    );
}

/*加载委托案件*/
function reload_delegateList(type)
{
	//页面的HTML(首页右侧，最高评分和活跃律师)
    var html = '<div class="midModel2Content_List"><div class="c1"><a href="/delegate/delegatelist.aspx?provinceid=$provinceid$" class="message_big">[$province$]</a></div><div class="c2"><a href="/delegate/delegatecontent.aspx?id=$ID$" class="message_big">$title$</a></div><div class="c3">$m$元</div><div class="c4">$time$</div></div>';
    //type = 0 是活跃 type = 1是高分
    var url = "/AjaxSource/CaseDelegateSource.ashx";
    $.getJSON(
        url,
        { type: type, rand: Math.floor(Math.random() * 10000).toString() },
        function (jsonData) {
            var outHtml='';
            for (var i = 0; i < jsonData.length; ++i) {
                if (outHtml == '')
                    outHtml = html.replace('$title$', jsonData[i].DelegateName).replace('$province$', jsonData[i].ProvinceName).replace('$m$', jsonData[i].InvolvedCaseMoney).replace('$time$', jsonData[i].TimeStr).replace('$provinceid$',jsonData[i].ProvinceID).replace('$ID$' ,jsonData[i].ID);
                else
                    outHtml += html.replace('$title$', jsonData[i].DelegateName).replace('$province$', jsonData[i].ProvinceName).replace('$m$', jsonData[i].InvolvedCaseMoney).replace('$time$', jsonData[i].TimeStr).replace('$provinceid$', jsonData[i].ProvinceID).replace('$ID$' ,jsonData[i].ID);
            }
            $("#delegateBox").empty();
            $("#delegateBox").html(outHtml);
        }
    );
    }

    function loadProvince(objectstr ,aboutobjectstr) {
        //页面的HTML(首页右侧，最高评分和活跃律师)
        var html = '<option value="$ProvinceID$">$ProvinceName$</option>';
        var url = "/AjaxSource/ProvinceSource.ashx";
        $.getJSON(
        url,
        function (jsonData) {
            var outHtml = '';
            for (var i = 0; i < jsonData.length; ++i) {
                if (outHtml == '') {
                    outHtml = html.replace('$ProvinceID$', jsonData[i].ID).replace('$ProvinceName$', jsonData[i].SName);
                } else {
                    outHtml += html.replace('$ProvinceID$', jsonData[i].ID).replace('$ProvinceName$', jsonData[i].SName);
                }
            }
            $("#" + objectstr).empty();
            $("#" + objectstr).append("<option value='0' selected='selected'>=省份=</option>"); 
            $("#" + objectstr).append(outHtml);
           //在前面插入一项option
            $("#" + objectstr).change(function () {
                loadCity(aboutobjectstr, $("#" + objectstr).val());
            });
        });
    }

    function loadCity(objectstr ,provinceid) {
        //页面的HTML(首页右侧，最高评分和活跃律师)
        var html = '<option value="$CityID$">$CityName$</option>';
        var url = "/AjaxSource/CitySource.ashx";
        $.getJSON(
        url,
        { provinceid: provinceid },
        function (jsonData) {
            var outHtml = '';
            for (var i = 0; i < jsonData.length; ++i) {
                if (outHtml == '') {
                    outHtml = html.replace('$CityID$', jsonData[i].ID).replace('$CityName$', jsonData[i].CityName);
                } else {
                    outHtml += html.replace('$CityID$', jsonData[i].ID).replace('$CityName$', jsonData[i].CityName);
                }
            }
            $("#" + objectstr).empty();
            $("#" + objectstr).append(outHtml);
            $("#" + objectstr).prepend("<option value='0'>=城市=</option>"); //在前面插入一项option
        });
    }

    function loadLegalAffairsBigClass(objectstr,laID) {
        var html = '<option value="$ID$">$Name$</option>';
        var url = "/AjaxSource/LegalAffairsSmallSource.ashx";
        var outHtml = '';
        $.getJSON(
        url,
        { classid:laID },
        function (jsonData) {
            for (var i = 0; i < jsonData.length; ++i) {
                if (outHtml == '') {
                    outHtml = html.replace('$ID$', jsonData[i].ID).replace('$Name$', jsonData[i].ClassName);
                } else {
                    outHtml += html.replace('$ID$', jsonData[i].ID).replace('$Name$', jsonData[i].ClassName);
                }
            }

            $("#" + objectstr).empty();
            $("#" + objectstr).append(outHtml);
            $("#" + objectstr).prepend("<option value='0' selected='selected'>=类别=</option>"); //在前面插入一项option
        });
    }

    function loadLegalAffairs(objectstr) {
        var html = '<option value="$laID$">$laName$</option>';
        var url = "/AjaxSource/LegalAffairsSource.ashx";
        var outHtml = '';
        $.getJSON(
        url,
        function (jsonData) {
            for (var i = 0; i < jsonData.length; ++i) {
                if (outHtml == '') {
                    outHtml = html.replace('$laID$', jsonData[i].ID).replace('$laName$', jsonData[i].Values);
                } else {
                    outHtml += html.replace('$laID$', jsonData[i].ID).replace('$laName$', jsonData[i].Values);
                }
            }

            $("#" + objectstr).empty();
            $("#" + objectstr).append(outHtml);
            $("#" + objectstr).prepend("<option value='0' selected='selected'>=类别=</option>"); //在前面插入一项option
        });
    }

    function loadInstrumentsSmallClass(objectstr  ,bigclassid) {
        var html = '<option value="$laID$">$laName$</option>';
        var url = "/AjaxSource/InstrumentsSource.ashx";
        var outHtml = '';
        $.getJSON(
        url,
        { bigclassid: bigclassid },
        function (jsonData) {
            for (var i = 0; i < jsonData.length; ++i) {
                if (outHtml == '') {
                    outHtml = html.replace('$laID$', jsonData[i].ID).replace('$laName$', jsonData[i].InstrumentsName);
                } else {
                    outHtml += html.replace('$laID$', jsonData[i].ID).replace('$laName$', jsonData[i].InstrumentsName);
                }
            }
            $("#" + objectstr).empty();
            $("#" + objectstr).append(outHtml);
            $("#" + objectstr).prepend("<option value='0' selected='selected'>请选择二级栏目</option>"); //在前面插入一项option
        });
    }

    //弹出确认框框
    function ConfirmDel(el_message) {
        if (confirm(el_message)) {
            return true;
        }
        else {
            return false;
        }
    }

    /**    *     * @param {} sURL 收藏链接地址    * @param {} sTitle 收藏标题    */function AddFavorite(sURL, sTitle) { try { window.external.addFavorite(sURL, sTitle); } catch (e) { try { window.sidebar.addPanel(sTitle, sURL, ""); } catch (e) { alert("加入收藏失败，请使用Ctrl+D进行添加"); } } }   /**    *     * @param {} obj 当前对象，一般是使用this引用。    * @param {} vrl 主页URL    */function SetHome(obj, vrl) { try { obj.style.behavior = 'url(#default#homepage)'; obj.setHomePage(vrl); } catch (e) { if (window.netscape) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。"); } var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); prefs.setCharPref('browser.startup.homepage', vrl); } } }   